<?php
class TaskVersionModel extends BaseModel
{
	/**
	 * 获取版本号
	 * @param int $tid
	 * @author ice<iceinto@mallog.com.cn>
	 */
	public function getVersion($tid){
		$map = array();
		$map['tid'] = $tid;
		$ver = $this->where($map)->order('create_time')->find();
		if($ver){
			return intval($ver['version']);
		}
		else{
			return 1;
		}
	}

	/**
	 * 添加一个版本记录
	 * @param array $data
	 * @author ice<iceinto@mallog.com.cn>
	 */
	public function addOne($data, $uid = null){
		$data['tid'] = $data['id'];
		if($uid){
			$data['return_uid'] = $uid;
		}
		unset($data['mall']);
		unset($data['floor']);
		unset($data['brand']);
		unset($data['id']);
		return $this->add($data);
	}
}